package com.lh.service;

import com.lh.dao.GoodsMapper;
import com.lh.dao.GoodsTypeMapper;
import com.lh.dao.GoodsVoMapper;
import com.lh.entity.Goods;
import com.lh.entity.GoodsType;
import com.lh.entity.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {

    @Autowired
    GoodsVoMapper goodsVoMapper;
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    GoodsTypeMapper goodsTypeMapper;

    public List<GoodsVo> findAll(GoodsVo goodsVo) {

        return goodsVoMapper.findAll(goodsVo);
    }

    public List<GoodsType> findAllGoodsType() {

        return goodsTypeMapper.selectAll();
    }

    public void add(Goods goods) {
        goodsMapper.insert(goods);
    }

    public void todel(Integer id) {
        goodsMapper.deleteByPrimaryKey(id);
    }

    public void update(Goods goods) {
        goodsMapper.updateByPrimaryKey(goods);
    }

    public Goods findUserById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }
}
